import happybase
import datetime

import pymysql

# 创建mysql数据库连接
conn = pymysql.connect(host="localhost", port=3306, user="root", passwd="root", db="data_analyze")
cursor = conn.cursor()
#
# 构造查询语句
start_date = '2024-05-01'
end_date = '2024-05-17'
query = f"SELECT * FROM hot_search WHERE ranking_time BETWEEN '{start_date}' AND '{end_date}'"

# 执行查询
cursor.execute(query)

# 获取查询结果
results = cursor.fetchall()

# 打印查询结果
for row in results:
    print(row)

# 关闭连接
cursor.close()
conn.close()
